<template>
  <div class="setting">
    <component :is="component" :lf="props.lf" :data="props.data" :setting-data="propsData" />
  </div>
</template>
<script lang="ts">
export default { name: "Setting" };
</script>
<script setup lang="ts">
import { SettingType } from "@/types/logic-flow";
import LogicFlow from "@logicflow/core";
import IndicatorSetting from "../components/setting/indicator_setting.vue";
import OperateSetting from "../components/setting/operate_setting.vue";
import IndicatorConfigSetting from "../components/setting/indciatorConfig_setting.vue";
import IndicatorManageAPI, {
  DataSourceList,
  TableListParameter,
} from "@/api/strategy/strategy-index-database";
const props = defineProps<{
  lf?: LogicFlow;
  data: LogicFlow.NodeData | LogicFlow.EdgeData;
  type: SettingType;
  indicatorId: number;
  indicatorIds?: any[];
}>();

/**
 * @description 标题
 */
const component = computed(() => {
  let comp = null as any;
  switch (props.type) {
    case "all":
      break;
    case "indicator":
      comp = IndicatorSetting;
      break;
    case "add_operate":
      comp = OperateSetting;
      break;
    case "cut_operate":
      comp = OperateSetting;
      break;
    case "multiply_operate":
      comp = OperateSetting;
      break;
    case "except_operate":
      comp = OperateSetting;
      break;
    case "greaterThan_operate":
      comp = OperateSetting;
      break;
    case "greaterThanOrEqual_operate":
      comp = OperateSetting;
      break;
    case "lessThan_operate":
      comp = OperateSetting;
      break;
    case "lessThanOrEqual_operate":
      comp = OperateSetting;
      break;
    case "indicatorConfig_operate":
      comp = IndicatorConfigSetting;
      break;
  }
  return comp;
});

const propsData = computed(() => {
  let settingProps = ref();
  switch (props.type) {
    case "all":
      break;
    case "indicator":
      settingProps = ref({
        indicatorId: props.indicatorId,
        ids: props.indicatorIds,
      });
      break;
    case "indicatorConfig_operate":
      settingProps = ref({
        indicatorId: props.indicatorId,
        ids: props.indicatorIds,
      });
      break;
    case "add_operate":
      settingProps = ref({
        title: "加法操作",
        operate: "+",
      });
      break;
    case "cut_operate":
      settingProps = ref({
        title: "减法操作",
        operate: "-",
      });
      break;
    case "multiply_operate":
      settingProps = ref({
        title: "乘法操作",
        operate: "*",
      });
      break;
    case "except_operate":
      settingProps = ref({
        title: "除法操作",
        operate: "/",
      });
      break;
    case "greaterThan_operate":
      settingProps = ref({
        title: "比较操作",
        operate: ">",
      });
      break;
    case "greaterThanOrEqual_operate":
      settingProps = ref({
        title: "比较操作",
        operate: ">=",
      });
      break;
    case "lessThan_operate":
      settingProps = ref({
        title: "比较操作",
        operate: "<",
      });
      break;
    case "lessThanOrEqual_operate":
      settingProps = ref({
        title: "比较操作",
        operate: "<=",
      });
      break;
  }
  return settingProps;
});
</script>
<style lang="scss" scoped>
.setting {
  box-sizing: border-box;
  padding: 20px 10px;
}
</style>
